package com.jiangman.weather.adapter;

/**
 * Created by secoro on 2017/4/26.
 */

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * 自定义ViewPager适配器
 */
//// TODO: 2017/4/26  天气适配求
public class MyPagerAdapter extends PagerAdapter {

    public List<View> listViews;
    private  List<String> titles;

    public MyPagerAdapter(ArrayList<View> mListViews, List<String> titles) {
        this.listViews = mListViews;
        this.titles=titles;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(listViews.get(position));
        return listViews.get(position);
    }

    @Override
    public int getCount() {
        return listViews.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(listViews.get(position));
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }
}